#ifndef dl_client_H
#define dl_client_H

#include <QObject>
#include <QVariantMap>
#include <QAbstractSocket>
#include "RobotCmdNode.hpp"

class QTcpSocket;
class QSharedMemory;

struct DLMsgRecv
{
	double x;
	double y;
	double z;
	double rx;
	double ry;
	double rz;
	quint16 state;
};

class DlClient : public QObject
{
	Q_OBJECT
public:
	explicit DlClient(int argc, char** argv, QObject* parent = nullptr);
	~DlClient();

	void connect2Host(const std::string& strIp, unsigned short usPort);

private slots:
	void connect2Host_p();
	void onSocketConnected();
	void onSocketReadReady();
	void onSocketError(QAbstractSocket::SocketError e);

private:
	void rosSpinThread();
	int parse(quint8* buf, int len);


private:
	QTcpSocket* m_socket;
	int argc_;
	char** argv_;
	std::shared_ptr<RobotCmdNode> m_robotCmdNode;
	std::thread m_ros_spin_thread;

	QString m_strIp;
	quint16 m_usPort;
};

#endif // dl_client_H
